package com.body.park.user.controller;

import com.body.park.auth.client.model.LoginVal;
import com.body.park.auth.client.utils.OauthUtils;
import com.body.park.common.response.ResponseEntity;
import com.body.park.user.client.UserTestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author chaoxian.wu
 * @DATE 2022/3/10 16:26
 */
@Slf4j
@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private UserTestService userTestService;

    @GetMapping("/get")
    public ResponseEntity<LoginVal> test() {
        LoginVal user = OauthUtils.getCurrentUser();
        return ResponseEntity.ok(user);
    }

    @GetMapping("/findById")
    public String findById(@RequestParam("id") Long id) {
//        userTestService.findById(id);
        return "success";
    }

    @GetMapping("/findRedisKey")
    public String findRedisKey(@RequestParam("key") String key) {
        return userTestService.findRedisKey(key);
    }

    @GetMapping("/setRedisKey")
    public String setRedisKey(@RequestParam("key") String key, @RequestParam("value") String value) {
        return userTestService.setRedisKey(key, value);
    }

    @GetMapping("/testRedisSon")
    public String testRedisSon() {
        return userTestService.testRedisSon();
    }

    @GetMapping("/testBloomFilterData")
    public boolean addBloomFilterData(@RequestParam("value") String value) {
        return userTestService.addBloomFilterData(value);
    }

    @GetMapping("/checkBloomFilterData")
    public boolean checkBloomFilterData(@RequestParam("value") Long value) {
        return userTestService.checkBloomFilterData(value);
    }

}
